<#assign ctx=springMacroRequestContext.contextPath />
<#include "/macro/publicMacro.ftl">
<#import "/macro/pagination.ftl" as Pagination>

<@header title="类目列表">
    <link href="${ctx}/resource/common/css/pagination.css" rel="stylesheet">
    <link href="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.min.css" rel="stylesheet">
</@header>

<@body>
    <h2 class="module-title">类目管理</h2>

    <div class="alert alert-primary" role="alert">
        <form class="form-inline form-margin" action="${ctx}/cmsCategory/list">
            <div class="form-group mx-sm-3 mb-2">
                <label for="tenantId" >租户：</label>
                <select class="form-control" name="tenantId" id="tenantId">
                    <#list tenants as tenant>
                        <option value="${tenant.id}" <#if tenant.id == cmsCategory.tenantId>selected</#if>>${tenant.description}</option>
                    </#list>
                </select>
            </div>
            <div class="form-group mx-sm-3 mb-2">
                <label for="name" >类目名称：</label>
                <input type="text" class="form-control" id="name" name="name" value="${cmsCategory.name}">
            </div>
            <div class="form-group mx-sm-3 mb-2">
                <label for="enable" >是否可用：</label>
                <select class="form-control" name="enable" id="enable">
                    <option value="">请选择</option>
                    <#list statusValues as status>
                        <option value="${status}" <#if status == cmsCategory.enable>selected</#if>>${status.desc}</option>
                    </#list>
                </select>
            </div>

            <div class="form-group mx-sm-3 mb-2">
                <button type="submit" class="btn btn-primary">查询</button>
            </div>

            <@shiro.hasPermission name="cmsCategory:toAdd">
            <div class="form-group mx-sm-3 mb-2" style="float:right">
                <span style="float:left"><a href="${ctx}/cmsCategory/toAdd">添加数据</a></span>
            </div>
            </@shiro.hasPermission>
        </form>
    </div>

    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
                <th>主键</th>
                <th>租户</th>
                <th>类目名称</th>
                <th>类目描述</th>
                <th>排序</th>
                <th>父id</th>
                <th>是否可用</th>
                <th>创建时间</th>
                <th>更新时间</th>
                <th>操作</th>
            </thead>
            <tbody>
            <#list cmsCategorys.beans as cmsCategory>
                <tr>
                    <th>${cmsCategory.id!}</th>
                    <th>${cmsCategory.tenant.name!}</th>
                    <th>${cmsCategory.name!}</th>
                    <th>${cmsCategory.description!}</th>
                    <th>${cmsCategory.index!}</th>
                    <th>${cmsCategory.parentId!}</th>
                    <th>${cmsCategory.enable.desc!}</th>
                    <th>${(cmsCategory.createTime?string('yyyy-MM-dd hh:mm:ss'))!} </th>
                    <th>${(cmsCategory.updateTime?string('yyyy-MM-dd hh:mm:ss'))!} </th>
                    <th><@shiro.hasPermission name="cmsCategory:view"><a class="btn btn-primary btn-sm" href="${ctx}/cmsCategory/view/${cmsCategory.id?c}" role="button" aria-pressed="true">详情</a></@shiro.hasPermission>
                        <@shiro.hasPermission name="cmsCategory:edit"><a class="btn btn-info btn-sm" href="${ctx}/cmsCategory/toEdit/${cmsCategory.id?c}" role="button" aria-pressed="true">编辑</a></@shiro.hasPermission>
                    </th>
                </tr>
            </#list>
            </tbody>
        </table>

        <@Pagination.pagination formId="cmsCategoryForm"
            pageNo=cmsCategorys.pageNo
            pageTotal=cmsCategorys.pageTotal
            total=cmsCategorys.total
            pageSize=cmsCategorys.pageSize
            action="${ctx}/cmsCategory/list">
        </@Pagination.pagination>
    </div>
</@body>

<@footer>
    <script src="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.full.min.js"></script>

    <script type="text/javascript">
        $(function () {
                $('#startCreateTime').datetimepicker({
                    format:'Y-m-d H:i:s',
                    lang:'zh'});
                $('#endCreateTime').datetimepicker({
                    format:'Y-m-d H:i:s',
                    lang:'zh'});
                $('#startUpdateTime').datetimepicker({
                    format:'Y-m-d H:i:s',
                    lang:'zh'});
                $('#endUpdateTime').datetimepicker({
                    format:'Y-m-d H:i:s',
                    lang:'zh'});
        });
    </script>

    <script src="${ctx}/resource/common/js/pagination.js"></script>
    <script src="${ctx}/resource/common/js/jquery.validate.min.js"></script>

</@footer>